<?php
/**
 * +--------------------------------------------------------+
 * @Created by Phpstorm.
 * @Category ImagesService.php
 * @Depiction
 * @Author hwy <429208948@qq.com>
 * @Date 2022/6/24  13:34
 * +--------------------------------------------------------+
 */

namespace App\Services\Swoole\Components;


use App\Util\FileSystem;
use Illuminate\Support\Facades\Cache;

class ImagesService implements ComponentsInterface
{
    public $ws;
    public $frame;

    /**
     * @return array
     * @throws \Psr\SimpleCache\InvalidArgumentException
     * @Depiction
     * @Author hwy <429208948@qq.com>
     * @Date 2022/6/24  17:15
     */
    public function handle()
    {

        $datas = $this->stockArticle->query()
            ->select('subjectId', 'type')
            ->orderBy('id', 'desc')
            ->limit(1)
            ->get();

        foreach ($datas as $data){
            $show_url = 'https://yanbaoshe.oss-cn-beijing.aliyuncs.com/images/prod-gb-share_zlArticle_' . $data['subjectId'] . '.png';
            // 拉取图片到本地
            $fileSystem = $fileSystem = new FileSystem('');
            $res['show_url'] = $fileSystem->getImage($show_url, 'prod-gb-share_zlArticle_' . $data['subjectId'] . '.png','downloads/');
        }



        return $res = response_success_msg('请求成功！');
    }

}
